package java101;

import java.util.*;


public class NumLetter {
	

	  public static void main(String[] args)
	  {
	    int n;
	    Scanner scan = new Scanner(System.in);
	    System.out.println("Enter an integer greater than 0 and up to 1000000000: ");
	    n  = scan.nextInt();
	 
	    if(n <= 0){
	      System.out.println("Enter numbers greater than 0.");
	    }
	    else
	    {
	      NumLetter a = new NumLetter();
	      int nA = n/1000000000;
	      int nB = n/100000000;
	      int nC = n/1000000;
	      int nD = n/100000;
	      int nE = n/1000;
	      int nF = n/100;
	      
	      if (nA != 0 && n >= 100)
	      a.pw(((nA)%100), " billion");
	      if (nB != 0)
	      a.pw(((nB)%10)," hundred");
	      if (nC != 0 && n >= 100)
	      a.pw(((nC)%100)," million");
	      if (nD != 0)
	      a.pw(((nD)%10)," hundred");
	      if (nE != 0 && n >= 100)
	      a.pw(((nE)%100)," thousand");
	      if (nF != 0)
	      a.pw(((nF)%10)," hundred");
	      a.pw((n%100)," ");
	    }
	  }
	 
	  public void pw(int n,String ch)
	  {
	    String  ones[]={" "," one"," two"," three"," four"," five"," six"," seven"," eight"," nine"," ten"," eleven"," twelve"," thirteen"," fourteen","fifteen"," sixteen"," seventeen"," eighteen"," nineteen"};
	 
	    String tens[]={" "," "," twenty"," thirty"," forty"," fifty"," sixty"," seventy"," eighty"," ninety"};
	 
	    if(n > 19) {
	     System.out.print(tens[n/10] + " " + ones[n%10]);
	    } 
	    else if (n < 19){ 
	    	System.out.print(ones[n]);
	    	}
	    
	 
	    if (n > 0 && ch == " million"){
	    	System.out.println(ch);
	    }
	    if (n > 0 && ch == " thousand"){
	    	System.out.println(ch);
	    }
	    if(n > 0 && ch == " hundred"){
	    	System.out.print(ch);
	    }
	    if (n >= 0 && ch != " hundred" && ch != " thousand" && ch != " million"){
	    	System.out.println(ch);
	    }
	
	  }
	}
